
#ifndef _Railgun_H_
#define _Railgun_H_

#include "Weapon.h"
#include "../Utils/Vector2D.h"
#include "../Graphics/ParticleSystem/ParticleSystem.h"
#include "../Graphics/ParticleSystem/ParticleEmitter.h"
#include "../Sound/Sound.h"

#include <set>


class RailgunBolt : public WeaponProjectile {
  public:
    RailgunBolt(Ship *parent_ship, float speed);
    ~RailgunBolt();

    void render(void);
    void update(void);
    bool active(void);

    bool resolveCollision(Ship *ship);
    bool resolveCollision(Weapon *weapon);
    bool resolveCollision(Map *map);

  private:
    const Ship *parent_ship;
    bool is_active;
    float life;

    Vector2D perp;
    Vector2D start_pos, end_pos;
    Vector2D orig_start_pos, orig_end_pos;

    ParticleSystem *explosion_psys;
    ParticleEmitter *explosion_emitter;


    Ship* findClosestShipCollision(Vector2D start, Vector2D end, Vector2D &rstart, Vector2D &rend);
};


class Railgun : public WeaponGenerator {
  public:

    Railgun(int ammo_count, int lifetime, Ship *pship);
    ~Railgun();

    bool shouldDiscard(void);
    bool fire(void);

  private:
    const SndInfo* bolt_sound;

};


#endif

